package org.xinjiang.data.migration.flush.convert;

import java.util.Collection;
import java.util.Random;

public abstract class BaseConvert<S, T> {

    private final String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

    private Random random = new Random();

    public abstract T convert(S s);

    public abstract Collection<T> converts(Collection<S> ss);

    public String generateRandomString() {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 8; i++) {
            int nextInt = random.nextInt(ALLCHAR.length());
            char randomChar = ALLCHAR.charAt(nextInt);
            stringBuilder.append(randomChar);
        }
        return stringBuilder.toString();
    }
}
